package com.chatcompetition.controller;


import com.chatcompetition.common.api.CommonPage;
import com.chatcompetition.domain.entity.CompetitionActivity;
import com.chatcompetition.service.ActivityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/admin/activity")
public class ActivityController {

    @Autowired
    private ActivityService activityService;
    //打印全部的信息（超级管理员的权限）
    


    // 查询所有活动
    @GetMapping("/activities")
    public List<CompetitionActivity> listAllActivities() {
        return activityService.listAllActivities();
    }

    // 添加人老师查询自己添加的所有活动
    @GetMapping("/activitiesAddTeachers")
    public List<CompetitionActivity> listAllActivitiesAddTeachers() {
        return activityService.listAllActivitiesAddTeachers();
    }



    // 查询所有活动（分页）
    @GetMapping("/activitiesPage")
    public CommonPage<CompetitionActivity> listAllActivities(
            @RequestParam(defaultValue = "1") int page,
            @RequestParam(defaultValue = "10") int size) {
        return activityService.listAllActivities(page, size);
    }

    // 添加人老师查询自己添加的所有活动（分页）
    @GetMapping("/activitiesAddTeachersPage")
    public CommonPage<CompetitionActivity> listAllActivitiesAddTeachers(
            @RequestParam(defaultValue = "1") int page,
            @RequestParam(defaultValue = "10") int size) {
        return activityService.listAllActivitiesAddTeachers(page, size);
    }




    @GetMapping("/{id}")
    public CompetitionActivity getById(@PathVariable Long id) {
        return activityService.getById(id);
    }

    @PostMapping("/save")
    public boolean save(@RequestBody CompetitionActivity activity) {
        return activityService.save(activity);
    }

    @PutMapping("/update")
    public boolean update(@RequestBody CompetitionActivity activity) {
        return activityService.update(activity);
    }

    @DeleteMapping("/{id}")
    public boolean delete(@PathVariable Long id) {
        return activityService.delete(id);
    }

    @GetMapping("/convert-to-activities")
    public List<String> convertCompetitionsToActivities() {
        return activityService.convertCompetitionsToActivities();
    }
}